<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="f"%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <script src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>
    <script type="text/javascript" src="./js/jquery.min.js"></script>
    <title>修改教师</title>
</head>
<style>
        .layui-form{
            height: 250px;
           padding-top: 30px;
        }
        .buttonOne{
           width: 50%;
           height: 40px;
           margin-top: 50px;
           padding-left: 40%;
        }
        .buttonOne button{
            margin-left: 20px;
        }
        .layui-input, .layui-textarea{
            width: 70%;
        }
        .layui-form-label{
            padding: 9px 30px;
        }
        .layui-form-select .layui-edge{
          right: 28%;
        }
        .layui-form-select dl{
                min-width: 70%;
                left: 30px;
            }
          
    </style>
<body>
    <form class="layui-form" id="form">
            <div class="layui-form-item">
                    <label class="layui-form-label">用户名</label>
                    <div class="layui-input-block">
                      <input type="text" name="te_username" value="${Teacher.te_username}" required  lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input">
                    </div>
                  </div>
            <div class="layui-form-item">
                <label class="layui-form-label">姓名</label>
                <div class="layui-input-block">
                    <input type="text" name="te_truename" value="${Teacher.te_truename}"  required  lay-verify="required" placeholder="请输入姓名" autocomplete="off" class="layui-input">
                </div>
                </div>
            <div class="layui-form-item">
                    <label class="layui-form-label">性别</label>
                    <div class="layui-input-block">
                        <input type="radio" value="男"  name="te_sex"title="男"  <f:if test="${Teacher.te_sex=='男' }">checked="checked"</f:if> >
                        <input type="radio" value="女"  name="te_sex" title="女" <f:if test="${Teacher.te_sex=='女' }">checked="checked"</f:if>>
                    </div>
                    </div>
            <div class="layui-form-item">
                    <label class="layui-form-label">所属院系</label>
                    <div class="layui-input-block">
                    <select name="te_dep_id" lay-verify="required">
		                <c:forEach items="${departments}" var="item">
			            	<option value="${item.dep_id}">${item.department}</option>	
			            </c:forEach>                              
	                </select>
                    </div>
                </div>
            <div class="layui-form-item">
                    <label class="layui-form-label">工号</label>
                    <div class="layui-input-block">
                        <input type="text" value="${Teacher.work_number}"  name="work_number" required  readonly="readonly"  autocomplete="off" class="layui-input">
                    </div>
                    </div>
            <div class="layui-form-item">
                    <label class="layui-form-label">职称</label>
                    <div class="layui-input-block">
                        <input type="text" value="${Teacher.te_title}"  name="te_title" required  lay-verify="required" placeholder="请输入职称" autocomplete="off" class="layui-input">
                    </div>
                    </div>
            <div class="layui-form-item">
                    <label class="layui-form-label">出生日期</label>
                    <div class="layui-input-block">
                        <input type="date" id="borrowtimebox" name="te_birth"  value="${Teacher.te_birth}" 
                            class="layui-input" placeholder="请输入">
                    </div>
                </div>
            <div class="layui-form-item">
                    <label class="layui-form-label">身份证号</label>
                    <div class="layui-input-block">
                        <input type="text" name="te_identifyID" value="${Teacher.te_identifyID}"  required  lay-verify="required" placeholder="请输入身份证号" autocomplete="off" class="layui-input">
                    </div>
                    </div>
            <div class="layui-form-item">
                    <label class="layui-form-label">国籍</label>
                    <div class="layui-input-block">
                        <input type="text" name="te_native" value="${Teacher.te_native}"  required  lay-verify="required" placeholder="请输入国籍" autocomplete="off" class="layui-input">
                    </div>
                    </div>
            <div class="layui-form-item">
                    <label class="layui-form-label">电话号码</label>
                    <div class="layui-input-block">
                        <input type="text" name="te_phone"  value="${Teacher.te_phone}"  required  lay-verify="required" placeholder="请输入电话号码" autocomplete="off" class="layui-input">
                    </div>
                    </div>
            <div class="layui-form-item">
                    <div class="layui-input-block buttonOne">
                        <button class="btn layui-btn" lay-submit lay-filter="formDemo">更新</button>
                        <button type="reset" class="layui-btn layui-btn layui-btn-warm">重置</button>
                    </div>
                </div>
    </form>
    
</body>

<script>
        layui.use('form',function(){
          var form = layui.form;
        });
        $(function(){
			$(".btn").click(function(){
				var url = "${pageContext.request.contextPath}/updataTeacher";
				var param = $("#form").serialize();
				$.post(url,param,function(data){
					alert(data);
					if(data.flag==0){
						alert(data.msg);
					}else if(data.flag==1){
						window.parent.location.reload();//页面刷新
						var index = parent.layer.getFrameIndex(window.name);
						parent.layer.close(index);
						alert(data.msg);
					}
				});
			});
		}); 
</script>
</html>